package com.mdb.model;

import com.mdb.annotation.Data;
import com.mdb.data.BaseModel;
import com.mdb.data.Condition;
import com.mdb.data.DBFactory;
import com.mdb.data.IDataHandler;
import com.mdb.data.ITable;
import com.mdb.data.Table;
import com.mongodb.BasicDBObject;

@Data
public class User extends BaseModel {
	
	private String name;
	private String sex;
	public User() {
		
	}
	public User(BasicDBObject o) {
		super(o);
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getSex() {
		return sex;
	}
	public void setSex(String sex) {
		this.sex = sex;
	}
	
	@Override
	public ITable getTable() {
		return Table.User;
	}
	
	public static void main(String[] args) {
		IDataHandler dataHandler = DBFactory.getMongoDBDataHandler();
		Condition[] con = new Condition[1];
		con[0] = new Condition("name","alibaba");
		User su = dataHandler.get(Table.User,con);
		System.out.println(su.getName()+":" + su.getSex());
	}
}
